package com.pl.listener.myEvent;

import com.pl.domain.User;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author shent
 */
@Service
public class UserService {
    @Resource
    private ApplicationContext applicationContext;

    /**
     * 发布事件
     *
     * @return
     */
    public User getUser2() {
        User user = new User(1L, "用户测试1", "123456");
        // 发布事件
        MyEvent event = new MyEvent(this, user);
        applicationContext.publishEvent(event);
        return user;
    }
}
